package com.min.redis.common.enums.base;

import lombok.AllArgsConstructor;
import lombok.Getter;
import org.apache.commons.lang3.StringUtils;

@Getter
@AllArgsConstructor
public enum ResponseStatusEnum {

    /**
     * 成功
     */
    SUCCESS("0", "成功"),

    /**
     * 内部异常
     */
    FAILED("500", "内部异常"),
    /**
     * 外部接口访问异常
     */
    RPC_INVOKER_FAILED("550", "外部接口访问异常"),

    PARAM_ILLEGAL("301", "参数非法"),

    TASK_OPERATING("310","任务操作进行中"),

    ;

    private final String code;

    private final String msg;

    public static ResponseStatusEnum of(String code) {
        if (StringUtils.isBlank(code)) {
            return null;
        }
        for (ResponseStatusEnum value : values()) {
            if (StringUtils.equals(value.getCode(), code)) {
                return value;
            }
        }
        return null;
    }
}
